package com.zxl.grocerymicroservicewechatmeal.utils;

import java.util.Random;

/**
 * @Author: zxl
 * @Description:
 * @Date: Created in 10:11 2017/11/16
 * @Modified By:
 */
public class KeyUtil {
    /**
     * 生成唯一的主键
     * 格式: 时间（精确到毫秒了）+随机数
     * @return
     */
    public static synchronized String genUniqueKey() {
        Random random = new Random();
        Integer number = random.nextInt(900000) + 100000;//六位随机数

        return System.currentTimeMillis() + String.valueOf(number);
    }
}
